<template>
  <v-scale-screen
    :delay="0"
    :box-style="{
      backgroundColor: '#051735',
    }"
  >
    <div class="srceen-box-bg">
      <Page-title back />
      <div class="monitor-title font32 f f-ai-c f-jc-c">监控设置</div>
      <div class="p20 f-col f-ai-c f-jc-c">
        <div class="w1700 h732 g g4 mt10 mr10 ml10 o-a">
          <Video-icc
            v-for="(item, index) in dataList"
            :key="item.channelCode"
            :url="item.url + '?token=' + item.token"
            :channel-code="item.channelCode"
            :index="index"
            class="video"
          />
        </div>
        <div class="f-1 mr100" style="width: 100%">
          <Pagination
            :total="total"
            :limit.sync="queryParams.pageSize"
            :page.sync="queryParams.pageNum"
            layout="prev, pager, next"
            prev-text="< 上一页"
            next-text="下一页 >"
            srceen
            @pagination="getList"
          />
        </div>
      </div>
    </div>
  </v-scale-screen>
</template>
<script>
import VideoIcc from "@/components/VideoIcc/index.vue";
import { screenMonitor } from "@/api/srceen/home";
export default {
  components: { VideoIcc },
  data() {
    return {
      total: 0, // 总条数
      queryParams: {
        pageNum: 1,
        pageSize: 12,
      },
      dataList: [], // 监控列表
      isFull: false, // 是否全屏
    };
  },
  mounted() {
    this.getList();
    document.addEventListener("fullscreenchange", this.handleKeyDown);
  },
  beforeUnmount() {
    window.removeEventListener("fullscreenchange", this.handleKeyDown);
  },
  methods: {
    // 获取监控列表
    getList() {
      screenMonitor(this.queryParams).then((res) => {
        this.dataList = res.rows || [];
        this.total = res.total;
      });
    },
    // 全屏播放
    handlePlay(domId) {
      if (this.isFull) return;
      const video = document.getElementById(domId);
      if (video.requestFullscreen) {
        video.requestFullscreen();
      } else if (video.webkitRequestFullscreen) {
        video.webkitRequestFullscreen();
      } else if (video.mozRequestFullScreen) {
        video.mozRequestFullScreen();
      } else if (video.msRequestFullscreen) {
        video.msRequestFullscreen();
      }
    },
    // 监听全屏
    handleKeyDown() {
      const isFullScreen =
        document.fullscreenElement ||
        document.mozFullScreenElement ||
        document.webkitFullscreenElement ||
        document.msFullscreenElement;
      this.isFull = isFullScreen ? true : false;
    },
  },
};
</script>
<style lang="scss" scoped>
.srceen-box-bg {
  height: 100%;
  width: 100%;
  background: url("~@/assets/img/bg.png");
  .monitor-title {
    font-family: YouSheiBlack;
    font-size: 32px;
    color: #45f4ff;
    letter-spacing: 2px;
  }
  .video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    &:nth-child(1) {
      margin-bottom: 10px;
    }
    &:nth-child(2) {
      margin-bottom: 10px;
    }
  }
}
</style>
